classdef VoMex < handle

  properties
    hdle_;
  end

  methods
    function this = VoMex(K, b, image_size, params)
      if nargin < 3, params = VoMex.DefaultParameters; end
      this.hdle_ = vo_mex('new', K, b, image_size, params);
    end

    function delete(this)
      vo_mex('delete', this.hdle_);
    end

    function result = addFrame(this, I, D)
      assert(isa(I, 'uint8'));
      assert(isa(D, 'single'));
      result = vo_mex('add_frame', this.hdle_, I, D);
      result.pose = double(result.pose);
    end
  end


  methods (Static)
    function p = DefaultParameters
      p = struct(...
        'numPyramidLevels', -1, ...
        'sigmaPriorToCensusTransform', 0.5, ...
        'sigmaBitPlanes', 0.5, ...
        'maxIterations', 100, ...
        'parameterTolerance', 1e-6, ...
        'functionTolerance', 1e-5, ...
        'gradientTolerance', 1e-6, ...
        'relaxTolerancesForCoarseLevels', 1, ...
        'lossFunction', 'Huber', ...
        'verbosity', 'Silent', ...
        'minTranslationMagToKeyFrame', 0.0, ...
        'minRotationMagToKeyFrame', 2.5, ...
        'maxFractionOfGoodPointsToKeyFrame', 0.5, ...
        'goodPointThreshold', 0.75, ...
        'descriptor', 'Intensity', ...
        'minSaliency', 2.5, ...
        'minNumPixelsForNonMaximaSuppresssion', 320*240, ...
        'nonMaxSuppRadius', 1, ...
        'maxTestLevel', 0);
    end
  end

end
